Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TypelevelEitherSyntax Rule #182

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Add TypelevelEitherSyntax Rule #182

wants to merge 2 commits into from

Conversation

TonioGela
Copy link
Member

I've tried to begin addressing #46.
The solution uses mutability since essentially the APIs ask you to (the only alternative is traversing the entire document multiple times).

The solution is also naive and it's merely syntactical: once it finds the expression Right(()) searches for one of those imports in any point of the document:

cats.syntax.all._
cats.syntax.either._
cats.syntax.either.catsSyntaxEitherObject

and if any of those is present it DOESN'T add the cats.syntax.either._ import.

A nice rework could include:

  1. Making the rule semantical, so that we can check that the function called is exactly scala.util.Right.apply
  2. Searching for every occurrence of the expression if any of those imports is present but starting from it and following the parent trees. If any of the occurrences doesn't have those imports in the chain of parent trees then adding a global import is more reasonable (despite the fact that it could always clash with a local import).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant